#include "testechoservice.h"

TestEchoService::TestEchoService()
{
}

void TestEchoService::testExecute()
{
    QByteArray result;
    QString message = "Message";

    {
        QByteArray block;
        QDataStream out(&block, QIODevice::WriteOnly);
        out << QString("ECHO")  << message;
        EchoService echoService;
        QDataStream in(block);
        result = echoService.execute(in);
    }

    QByteArray expected;

    {
        QDataStream out(&expected, QIODevice::WriteOnly);
        out << quint16(0) << QString("RESULT") << message;
        out.device()->seek(0);
        out << quint16(expected.size() - sizeof(quint16));
    }

    QCOMPARE(result, expected);
}
